<?php
    include_once('Configs/database.php');
    include_once('HocPhan.php');
    include_once('NganhHoc.php');
    include_once('DeCuongHPChiTiet.php');
    class DeCuongHocPhan extends database{
        private $manganh;
        private $mahp;
        private $sotietbatbuoc;
        private $sotiettuchon;
       
        private $thongtingv;
        private $hptienquyet;
        private $muctieu;
        private $ppgiangday;
        private $danhgiahp;        
        private $tailieuthamkhao;
        //private $dsdecuonghpchitiet;//kieu DeCuongHPChiTiet
        private $tenfile;
        public function setMaNganh($manganh){
            $this->manganh = $manganh;
        }
        public function setMaHP($mahp){
            $this->mahp = $mahp;
        }
        public function setSoTietBatBuoc($sotietbatbuoc){
            $this->sotietbatbuoc = $sotietbatbuoc;
        }
        public function setSoTietTuChon($sotiettuchon){
            $this->sotiettuchon = $sotiettuchon;
        }
        
        public function setThongTinGV($thongtingv){
            $this->thongtingv = $thongtingv;
        }
        public function setHPTienQuyet($hptienquyet){
            $this->hptienquyet = $hptienquyet;
        }
        public function setMucTieu($muctieu){
            $this->muctieu = $muctieu;
        }
        public function setPPGiangDay($ppgiangday){
            $this->ppgiangday = $ppgiangday;
        }
        public function setDanhGiaHP($danhgiaHP){
            $this->danhgiahp = $danhgiaHP;
        }
        public function setTaiLieuThamKhao($tailieuthamkhao){
            $this->tailieuthamkhao = $tailieuthamkhao;
        }
        public function setTenFile($tenfile){
            $this->tenfile = $tenfile;
        }
        public function getMaNganh(){
            return $this->manganh;
        }
        public function getMaHP(){
            return $this->mahp;
        }
        public function getSoTietBatBuoc(){
            return $this->sotietbatbuoc;
        }
        public function getSoTietTuChon(){
            return $this->sotiettuchon;
        }
        
        
        public function getThongTinGV(){
            return $this->thongtingv;
        }
        public function getHPTienQuyet(){
            return $this->hptienquyet;
        }
        public function getMucTieu(){
            return $this->muctieu;
        }
        public function getPPGiangDay(){
            return $this->ppgiangday;
        }
        public function getDanhGiaHP(){
            return $this->danhgiahp;
        }
        public function getTaiLieuThamKhao(){
            return $this->tailieuthamkhao;
        }
        public function getTenFile(){
            return $this->tenfile;
        }
        /*public function __construct(){
            $this->manganh = '';
            $this->mahp = '';
            $this->sotietbatbuoc = 0;
            $this->sotiettuchon = 0;
            $this->sotietlithuyet = 0;
            $this->sotietthuchanh = 0;
            $this->thongtingv = '';
            $this->hptienquyet = '';
            $this->muctieu = '';
            $this->ppgiangday = '';
            $this->thongtingv = '';
            $this->tailieuthamkhao = '';
            $this->filepath = '';
        }
        public function DeCuongChitietHocPhan($manganh, $mahp, $sotietbb, $sotiettc,$sotietlt,$sotietth,$thongtingv,$hptq,$muctieu,$ppgiangday,$danhgiahp,$tailieuthamkhao,$filepath){
            $this->manganh = $manganh;
            $this->mahp = $mahp;
            $this->sotietbatbuoc = $sotietbb;
            $this->sotiettuchon = $sotiettc;
            $this->sotietlithuyet = $sotietlt;
            $this->sotietthuchanh = $sotietth;
            $this->thongtingv = $thongtingv;
            $this->hptienquyet = $hptq;
            $this->muctieu = $muctieu;
            $this->ppgiangday = $ppgiangday;
            $this->thongtingv = $danhgiahp;
            $this->tailieuthamkhao = $tailieuthamkhao;
            $this->filepath = $filepath;
        }*/       
        /*private $dshocphan;//kieu HocPhan
        private $dsnganh;// kieu NganhHoc
        
        public function setDSHocPhan(){
            $hp = new HocPhan();
            $this->dshocphan = $hp->dsTatCaHP();
        }
        public function getDSHocPhan(){
            return $this->dshocphan;
        }
        public function setDSNganh(){
            $nganh= new NganhHoc();
            $this->dsnganh = $nganh->dsTatCaNganh();
        }
        public function getDSNganh(){
            return $this->dsnganh;
        }*/
        public function dsNganh(){
            $nganh= new NganhHoc();
            return $nganh->dsTatCaNganh();
        }
        public function dsHocPhan(){
            $hp= new HocPhan();
            return $hp->dsTatCaHP();
        }
        /*public function setDSDeCuongHPChiTiet(){
            $decuongct= new DeCuongHPChiTiet();
            $this->dsdecuonghpchitiet = $decuongct->dsDeCuongCTTheoNganhHP($this->manganh, $this->mahp);
        }
        public function getDeCuongHPChiTiet(){
            return $this->dsdecuonghpchitiet;
        }*/
        public function dsDeCuongHPChiTiet(){
            $decuongct= new DeCuongHPChiTiet();
            return $decuongct->dsDeCuongCTTheoNganhHP($this->getMaNganh(), $this->getMaHP());
        }
        public function themDeCuongHP(){                
            $query = "insert into DeCuongHocPhan(manganh, mahp, sotietbatbuoc, sotiettuchon, thongtingv, hptienquyet,muctieu,ppgiangday,danhgiahp,tailieuthamkhao,tenfile) ";
            $query .= "values ('".$this->getMaNganh()."','".$this->getMaHP()."',".$this->getSoTietBatBuoc().",".$this->getSoTietTuChon().",";
            $query .= "'".$this->getThongTinGV()."','".$this->getHPTienQuyet()."','".$this->getMucTieu()."','".$this->getPPGiangDay()."','".$this->getDanhGiaHP()."','".$this->getTaiLieuThamKhao()."','".$this->getTenFile()."')";
            $this->setQuery($query); 
            echo $this->getQuery();            
            //return $this->executeQuery();
         }
         public function kiemTraTonTai($manganh,$mahp){
             //return $this->isExits("NguoiDung","maso='". $this->maso."' and matkhau = '".$this->matkhau."'");
             return $this->isExits("DeCuongHocPhan","manganh='".$manganh."' and mahp='".$mahp."'");
         }
         public function thongTinDeCuongHP(){
            $query = "select a.mahp, tenhp,  sotc, sotietlithuyet, sotietthuchanh, thongtingv, 
						hptienquyet, muctieu, ppgiangday ,danhgiahp, tailieuthamkhao ,tenfile, tenkhoa ";
            $query .= "from HocPhan a, ChuongTrinhDaoTao b, NganhHoc c, Khoa d ";
            $query .= "where a.mahp=a.mahp='".$this->getMaHP()."' and a.mahp = b.mahp and b.manganh = c.manganh and c.makhoa = d.makhoa";
            //$this->setQuery("select * from DeCuongHocPhan a, HocPhan b, NganhHoc c, Khoa d where  a.mahp='".$this->getMaHP()."' and a.manganh='".$this->getMaNganh()."' and a.mahp = b.mahp and a.manganh = c.manganh and c.makhoa=d.makhoa");
            $this->setQuery($query);
            return $this->fetchAll();
         }
         public function suaDeCuongHP(){
            $query = "update DeCuongHocPhan set sotietbatbuoc=".$this->getSoTietBatBuoc().", sotiettuchon=".$this->getSoTietTuChon().",";
            $query .= "thongtingv='".$this->getThongTinGV()."', hptienquyet='".$this->getHPTienQuyet()."',muctieu='".$this->getMucTieu()."',";
            $query .= "ppgiangday='".$this->getPPGiangDay()."',danhgiahp='".$this->getDanhGiaHP()."',tailieuthamkhao='".$this->getTaiLieuThamKhao()."',tenfile='".$this->getTenFile()."' where manganh='".$this->getMaNganh()."' and mahp='".$this->getMaHP()."' ";
           
            $this->setQuery($query);                         
            return $this->executeQuery();
         }
         public function xoaDeCuongHP(){
            $this->setQuery("delete from DeCuongHocPhan where manganh='".$this->manganh."' and mahp='".$this->mahp."'");
            return $this->executeQuery();
         }
    }
?>
